package com.ruoyi.web.home.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.web.home.service.IHomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

/**
 * @author liuyu
 */
@RestController
@RequestMapping("/home")
public class HomeController {

    @Autowired
    private IHomeService iHomeService;

    /**
     * 获取审核人首页面板数据
     */
    @GetMapping(value = "/operate/getPanelGroup")
    public AjaxResult getOperatePanelGroup()
    {
        return AjaxResult.success(iHomeService.getOperatePanelGroup());
    }

    /**
     * 获取投资人首页面板数据
     */
    @GetMapping(value = "/invest/getPanelGroup")
    public AjaxResult getInvestPanelGroup()
    {
        return AjaxResult.success(iHomeService.getInvestPanelGroup());
    }

    /**
     * 获取发行人首页的图表数据
     */
    @GetMapping(value = "/publish/getChartData")
    public AjaxResult getPublishChartData()
    {
        return AjaxResult.success(iHomeService.getPublishChartData());
    }

    /**
     * 获取投资人首页的图表数据
     */
    @GetMapping(value = "/invest/getChartData")
    public AjaxResult getInvestChartData()
    {
        return AjaxResult.success(iHomeService.getInvestChartData());
    }

    /**
     * 获取投资人首页的图表数据
     */
    @GetMapping(value = "/operate/getChartData")
    public AjaxResult getOperateChartData() throws ParseException {
        return AjaxResult.success(iHomeService.getOperateChartData());
    }

    /**
     * 获取首页的股票排名
     */
    @GetMapping(value = "/operate/getStockRankTop10")
    public AjaxResult getOperateStockRankTop10()
    {
        return AjaxResult.success(iHomeService.getStockRankTop10());
    }

    /**
     * 获取首页的股票排名
     */
    @GetMapping(value = "/invest/getStockRankTop10")
    public AjaxResult getInvestStockRankTop10()
    {
        LoginUser sysUser = SecurityUtils.getLoginUser();
        return AjaxResult.success(iHomeService.getStockRankTop10(sysUser.getUserId()));
    }


}
